import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2024-11-27
 * Time: 20:52
 */
public class shell {
    public static void sort(int[] arr){
        int gap=arr.length/2;
        //开始遍历
        int j=1;
        do{
            for(int i=0;i<arr.length-gap;i++){
                if(arr[i]>arr[i+gap]){
                    //交换
                    int tmp=arr[i];
                    arr[i]=arr[i+gap];
                    arr[i+gap]=tmp;
                }
            }
            gap/=2;
            System.out.println("第"+j+++"次: "+Arrays.toString(arr));
        }while(gap>=1);
    }
    public static void main(String[] args) {
        int[] arr=new int[]{1,56,88,66,35,2,8};
        sort(arr);
    }
}
